<?php
/**
 * Created by Sven.
 * Date: 2016/12/30
 * Time: 14:09
 * (
 * [name] => animal.jpg
 * [type] => image/jpeg
 * [tmp_name] => E:\software\xampp\tmp\php9D9F.tmp
 * [error] => 0
 * [size] => 6620
 * )
 */

include dirname( dirname( __FILE__ ) ) . '/includes/init.inc.php';

if ( IS_POST ) {
    if ( $_POST ) {

        $_upload = new FileUpload( 'pic', $_POST[ 'MAX_FILE_SIZE' ] );
        if ( $_upload->upload() ) {
            $_linkPath = $_upload->getLinkPath();
            echo <<<EOF
<script>
       window.opener.document.content.thumbnail.value = '$_linkPath';
       window.opener.document.getElementById('thumbnailImg').src = '\/{$_linkPath}';
       window.opener.document.getElementById('thumbnailImg').width = '200';
       window.opener.document.getElementById('thumbnailImg').height = '150';
       
       window.close();
       
</script>
EOF;

        }
    } else {
        exit( '警告：可能因为文件过大，导致上传失败' );
    }

} else {
    exit( '警告：禁止GET方式访问此脚本' );
}




